import Mock from 'mockjs'

// 配置Mock
Mock.setup({
  timeout: '200-600' // 设置响应时间
})

// 登录接口
Mock.mock(/\/api\/login/, 'post', {
  code: 200,
  data: {
    token: 'mock-token',
    userInfo: {
      id: 1,
      username: 'admin',
      avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
      roles: ['admin']
    }
  },
  message: '登录成功'
})

// 获取用户信息
Mock.mock(/\/api\/user\/info/, 'get', {
  code: 200,
  data: {
    id: 1,
    username: 'admin',
    avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
    roles: ['admin']
  },
  message: '获取成功'
})

// 上传头像
/*
Mock.mock(/\/api\/upload/, 'post', {
  code: 200,
  data: {
    url: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'
  },
  message: '上传成功'
})
*/

// 根据productId获取商品评价列表
/*
Mock.mock(/\/api\/assess\/assess\/user\/product/, 'get', (options) => {
  const url = new URL(options.url, 'http://localhost')
  const productId = url.searchParams.get('productId')
  
  console.log(`Mocking request for productId: ${productId}`)

  // 生成模拟评价数据
  const assessList = [
    {
      userId: 101,
      isAnonymous: 0,
      content: "使用一周后才来评价，确实不错。",
      rating: 4
    },
    {
      userId: 102,
      isAnonymous: 1,
      content: "商品符合预期，性价比很高，值得推荐。",
      rating: 5
    },
    {
      userId: 103,
      isAnonymous: 0,
      content: "非常棒的商品，超出了我的预期，下次还会继续购买！",
      rating: 5
    }
  ]
  
  return {
    code: 200,
    msg: "查询成功",
    data: assessList,
  }
}) 
*/ 